package com.example.aijiancece.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.aijiancece.database.dao.HistoryDao;
import com.example.aijiancece.database.entity.HistoryEntity;

@Database(entities = {HistoryEntity.class}, version = 1)
public abstract class HistoryDatabase extends RoomDatabase {
    private static final String DATABASE_NAME = "history_db";
    private static HistoryDatabase instance;

    public abstract HistoryDao historyDao();

    public static synchronized HistoryDatabase getInstance(Context context) {
        if (instance == null) {
            instance = Room.databaseBuilder(
                    context.getApplicationContext(),
                    HistoryDatabase.class,
                    DATABASE_NAME
            ).build();
        }
        return instance;
    }
} 